class Task67:
    def run(self, string):
        if len(string) == 0:
            raise ValueError('empty string')

        is_positive = True
        index = 0
        if string[0] == '+':
            is_positive = True
            index = 1
        elif string[0] == '-':
            is_positive = False
            index = 1

        result = 0
        for i in range(index, len(string)):
            char = string[i]
            if '0' <= char <= '9':
                result = result * 10 + ord(char) - ord('0')
            else:
                raise ValueError('invalid number format')

        if not is_positive:
            result = -result
        return result
